package com.winit.openapi.ums.controller;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONObject;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ums.spi.commnad.CodeCommand;
import com.winit.ums.spi.supplier.SupplierService;
import com.winit.ums.spi.vo.SupplierClassVo;

@Controller
@RequestMapping(value = "/ums/supplier")
public class UmsSupplierController extends BaseController{

    @Resource
    private SupplierService umsSupplierService;
    
    @RequestMapping(value = "/querySuppliersByGroupCode")
    public String querySuppliersByGroupCode(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg){
        // 获取参数
        JSONObject json = JSONObject.parseObject(requestMsg.getData().toString());
        CodeCommand command = new CodeCommand();

        String groupCode = (String) json.get("groupCode");
        command.setCode(groupCode);
        if (StringUtils.isNotBlank(groupCode)) {
            List<SupplierClassVo> supplierClassVos = umsSupplierService.querySuppliersByGroupCode(command);
            responseMsg.setData(supplierClassVos);
        }
        return SUCCESS;
    }
}
